package nowCoder;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class HJ41 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] m = new int[n];
        for (int i = 0; i < n; i++) {
            m[i] = in.nextInt();
        }
        int[] x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = in.nextInt();
        }
        Set<Integer> s = new HashSet<>();
        s.add(0);
        Set<Integer> ss = new HashSet<>();
        for (int i = 0; i < n; i++) {
            int mm = m[i];
            int xx = x[i];
            for (int j = 1; j <= xx; j++) {
                if (i == 0){
                    ss.add(mm*j);
                }else
                    for (Integer integer : s) {
                        ss.add(integer + (mm*j));
                    }
            }
            s.addAll(ss);
        }
        System.out.println(s.size());
    }
}
